Create a generic interface:
public interface DAO <T,IdType> {
public IdType createOrUpdate( T object );
public List<T> list();
public T get( IdType id );
public void delete( IdType id );
}
Create a business intrface derived from the generic:
public interface EventFacade extends DAO <Event,Integer> {
...
}
Implement the business object derived from the interface:
public class EventFacadeBean implements EventFacade {
public Integer createOrUpdate(Event event) {
// TODO Auto-generated method stub
return null;
}
public Event get(Integer id) {
// TODO Auto-generated method stub
return null;
}
public Listlist() {
// TODO Auto-generated method stub
return null;
}
public void delete(Integer id) {
// TODO Auto-generated method stub
return false;
}
...
}
As you can see the DAO interface is no longer generic in the concrete implementation of the class. This makes maitenece a LOT less tedious and definitely helps with implementing "patterns."